#ifndef WIDGET_H
#define WIDGET_H

#include <QCheckBox>
#include <QLineEdit>
#include <QPushButton>
#include <QSerialPort>
#include <QTimer>
#include <QWidget>



QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();


signals:
    void btnSend_clicked(int index);


private slots:
    void on_btnOpenOrClose_clicked(bool checked);

    void on_btnSend_clicked();

    void on_Send_str(int index);

    void on_Rec_str();

    void on_checkBoxHex_clicked(bool checked);

    void on_checkBoxTimerSend_clicked(bool checked);

    void on_btnClearRec_clicked();

    void on_btnSavaRcv_clicked();

    void on_btnHidePanel_clicked(bool checked);

    void on_btnHideHistory_clicked(bool checked);

    void on_checkBoxLoop_clicked(bool checked);

    void on_LoopTimer_clicked();

    void on_btnSaveText_clicked();

    void on_btnLoadText_clicked();

    void on_btnResetText_clicked();

private:
    QString toHexWithPrefix(const QString& strconvers);

    QString fromHexWithPrefix(const QString& strconvers);

    void handleSerialError(QSerialPort::SerialPortError error);

    void  addSerialPort();

private:
    Ui::Widget *ui;
    QSerialPort* serialPort;
    QTimer* timer,*CurTimer,*LoopTimr;

    int index;

    QString lastStr;

    QList<QPushButton*> btnList;
    QList<QLineEdit*>   LineEditList;
    QList<QCheckBox*>   CheckList;



};
#endif // WIDGET_H
